package com.iee.webbase.async;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.web.context.request.async.DeferredResult;

/**
 *@ClassName HelloService
 *@Description TODO
 *@Author longxiaonan@163.com
 *@Date 2022/4/21 0021 22:22
 */
@Service
public class HelloService {

    private static final Logger logger = LoggerFactory.getLogger(HelloService.class);

    public String sayHello() {
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        logger.info("HelloService.sayHello()");
        return "HelloService";
    }

    public void execute(DeferredResult<String> deferredResult) {
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        logger.info("HelloService.execute()");
        deferredResult.setResult("service执行完毕");
    }
}
